import {useStore} from "vuex";
import {UserPermissionDAT} from "../types/responseTypes";

export function usePermission(){
    const {getters,state} = useStore()
    function can(QX_ID: number){
        if (!state.user.hasLogIn){
            return false
        }
        const permissions: UserPermissionDAT[] = getters.permissions
        return permissions.findIndex(item => item.QX_ID === QX_ID) !== -1
    }

    return {
        can
    }
}
